//
//  ByCellGetScoreFromPay.m
//  mijifen_ios
//
//  Created by 朱凯 on 2017/11/7.
//  Copyright © 2017年 itboye. All rights reserved.
//

#import "ByCellGetScoreFromPay.h"

// vc
#import "ByGetScoreFromPayDetailVC.h"

@implementation ByCellGetScoreFromPay
{
    UIView *_lastView;
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        [self setupUI];
    }
    return self;
}

- (void)setupUI {
    
    UIView *lastView;
    
    CGFloat margin = 1;
    
    for (int i = 0; i < 3; i ++) {
        
        UIControl *basalView = [UIControl new];
        [self.contentView addSubview:basalView];
        basalView.tag = 10 + i;
        [basalView addTarget:self action:@selector(touchAction:) forControlEvents:UIControlEventTouchUpInside];
        
        // 图片
        UIImageView *iconView = [UIImageView new];
        iconView.tag = 1;
        iconView.backgroundColor = BY_BLUE_COLOR;
        [basalView addSubview:iconView];
        // 文字
        UILabel *label = [[UILabel alloc] init];
        label.backgroundColor = BY_RED_COLOR;
        label.tag = 2;
        label.adjustsFontSizeToFitWidth = true;
        label.font = FONT(12);
        label.textAlignment = NSTextAlignmentCenter;
        label.textColor = [UIColor whiteColor];
        [basalView addSubview:label];
        UIBezierPath *path = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(0, 0, SCREEN_WIDTH * 0.7, 20) byRoundingCorners:UIRectCornerBottomRight | UIRectCornerTopRight cornerRadii:CGSizeMake(10, 10)];
        CAShapeLayer *masker = [CAShapeLayer new];
        masker.backgroundColor = BY_RED_COLOR.CGColor;
        masker.path = path.CGPath;
        label.layer.mask = masker;
        
        // 布局
        [basalView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.width.equalTo(self.contentView).multipliedBy(1.0 / 3);
            make.height.equalTo(basalView.mas_width);
            // 第一个
            if (i == 0) {
                make.left.equalTo(@0);
            } else {
                make.left.equalTo(lastView.mas_right).offset(margin);
            }
        }];
        
        [iconView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.edges.equalTo(basalView);
        }];
        [label mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.top.equalTo(@0);
            make.width.equalTo(basalView).multipliedBy(0.7);
            make.height.equalTo(@20);
        }];
        
        lastView = basalView;
    }
  
}

- (void)touchAction:(UIControl *)sender {
    
//    NSInteger index = sender.tag - 10;
    
    ByGetScoreFromPayDetailVC *vc = [ByGetScoreFromPayDetailVC new];
    [((ByBaseVC *)self.viewController) by_normalPush:vc hasNavi:true];
    
}


@end
